package com.glidebitmappool.internal;

import ohos.media.image.PixelMap;
import ohos.media.image.common.PixelFormat;
import ohos.media.image.common.Size;

/**
 * 位图池实现类，原库 API 11 之前使用
 *
 * @author renpengfei
 * @since 2021-03-12
 */
public class BitmapPoolAdapter implements BitmapPool {
    @Override
    public int getMaxSize() {
        return 0;
    }

    @Override
    public void setSizeMultiplier(float sizeMultiplier) {
        // Do nothing.
    }

    @Override
    public void put(PixelMap bitmap) {
        bitmap.release();
    }

    @Override
    public PixelMap get(int width, int height, PixelFormat config) {
        PixelMap.InitializationOptions initializationOptions = new PixelMap.InitializationOptions();
        initializationOptions.size = new Size(width,height);
        initializationOptions.pixelFormat = config;
        return PixelMap.create(initializationOptions);
    }

    @Override
    public PixelMap getDirty(int width, int height, PixelFormat config) {
        return get(width, height, config);
    }

    @Override
    public void clearMemory() {
        // Do nothing.
    }

    @Override
    public void trimMemory(int level) {
        // Do nothing.
    }
}